Skip to main content

While Loop

Flow-Wing supports the while keyword to iterate over a sequence of values.

Example Usage:

var i: int = 0

while i < 10 {
  print(i + " ")
  i = i + 1
}

Output:

0 1 2 3 4 5 6 7 8 9

Example Usage: With Break

var i: int = 0

while i < 10 {
  if i == 5 {
      break
  }
  print(i + " ")
  i = i + 1
}

Output:

0 1 2 3 4

Example Usage: With Continue

var i: int = 0

while i < 10 {
  if i == 5 {
      i = i + 1
      continue
  }
  print(i + " ")
  i = i + 1
}

Output:

0 1 2 3 4 6 7 8 9